/** ***********************************************
 * CodeGen
 *
 * @author  Jonnie Spratley
 * @date 3/05/2009
 * @licence MCIYC
 * @website http://jonniespratley.com/code
 * @contact jonniespratley@gmail.com
 *********************************************** */
package com.jonniespratley.codegen.control
{
	import com.adobe.cairngorm.control.FrontController;
    import com.jonniespratley.codegen.commands.*;
    import com.jonniespratley.codegen.events.*;

	/**
	 * The Front Controller is a central place where all the commands are mapped to
	 * the relevant events. Once an event is dispatched, the Front Controller finds
	 * the corresponding command to execute.
	 */
	public final class CodeGenController extends FrontController
	{
		public function CodeGenController()
		{
			this.initialize();
		}

		private function initialize() : void
		{
			//Map events.WHAT TYPE OF EVENT, to COMMAND
			this.addCommand( CallMethodEvent.CALL_METHOD_EVENT, CallMethodCommand );
		    this.addCommand( GetDirectoryEvent.GET_DIRECTORY_EVENT, GetDirectoryCommand );
		    this.addCommand( ReadFileEvent.READ_FILE_EVENT, ReadFileCommand );
		    this.addCommand( WriteFileEvent.WRITE_FILE_EVENT, WriteFileCommand );
		    this.addCommand( SelectedFileEvent.SELECTED_FILE_EVENT, SelectedFileCommand );

		    this.addCommand( GetDatabasesEvent.GET_DATABASES_EVENT, GetDatabasesCommand );
		    this.addCommand( GenerateConfigEvent.GENERATE_CONFIG_EVENT, GenerateConfigCommand );
		    this.addCommand( GenerateSchemaEvent.GENERATE_SCHEMA_EVENT, GenerateSchemaCommand );
		    this.addCommand( GenerateApplicationEvent.GENERATE_APPLICATION_EVENT, GenerateApplicationCommand );
		    this.addCommand( GetSchemaEvent.GET_SCHEMA_EVENT, GetSchemaCommand );
		    this.addCommand( GetConfigEvent.GET_CONFIG_EVENT, GetConfigCommand );
		    this.addCommand( GetApplicationEvent.GET_APPLICATION_EVENT, GetApplicationCommand );
		    this.addCommand( GetTemplatesEvent.GET_TEMPLATES_EVENT, GetTemplatesCommand );
		    this.addCommand( GetOutputEvent.GET_OUTPUT_EVENT, GetOutputCommand );
		    this.addCommand( InspectPHPClassEvent.INSPECT_PHP_CLASS_EVENT, InspectPHPClassCommand );
		    this.addCommand( GetServicesEvent.GET_SERVICES_EVENT, GetServicesCommand );
		    this.addCommand( CallClassFunctionEvent.CALL_CLASS_FUNCTION_EVENT, CallClassFunctionCommand );
		    //todo: add commands
		}
	}
}
